package top.xtcoder.jdcbase.base.core;

import java.lang.reflect.Field;

/**
 * 用户类型
 * @author xiangtao
 *
 */
public class UserType {
	public final static String getPermName(int type) {
		return getName(type, "permName");
	}
	public final static String getRoleName(int type) {
		return getName(type, "roleName");
	}
	public final static String getName(int type, String name) {
		Class[] clss = UserType.class.getDeclaredClasses();
		for(Class cls : clss) {
			try {
				Field field = cls.getField("type");
				int t = field.getInt(null);
				if(type == t) {
					Field fieldPermName = cls.getField(name);
					return (String)fieldPermName.get(null);
				}
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		throw new RuntimeException("【" + type + "】没有对应的类型");
	}
	
	/**
	 * 后台管理员
	 * @author xiangtao
	 *
	 */
	public class Admin {
		public final static String permName = "PrRbacAdminPerm";
		public final static String roleName = "PrRbacAdminRole";
		public final static int type = 1000;
	}
	
	/**
	 * 前台/APP等普通用户
	 * @author xiangtao
	 * 
	 */
	public class Member {
		public final static String permName = "PrRbacMemberPerm";
		public final static String roleName = "PrRbacMemberRole";
		public final static int type = 1001;
	}
	
	/**
	 * 商户用户
	 * @author xiangtao
	 * 
	 */
	public class Merchant {
		public final static String permName = "PrRbacMemberPerm";
		public final static String roleName = "PrRbacMemberRole";
		public final static int type = 1002;
	}
	
	/**
	 * 教师用户
	 * @author xiangtao
	 * 
	 */
	public class Teacher {
		public final static String permName = "PrRbacTeacherPerm";
		public final static String roleName = "PrRbacTeacherRole";
		public final static int type = 1003;
	}
	
	/**
	 * 学生用户
	 * @author xiangtao
	 * 
	 */
	public class Student {
		public final static String permName = "PrRbacStudentPerm";
		public final static String roleName = "PrRbacStudentRole";
		public final static int type = 1004;
	}
}
